<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>jsDmeo</title>
    <!-- <script src="tools.js"></script> -->
</head>
<body>
    <div>
        <h3>这是一个猜数字的游戏</h3>
        <p></p>
        请输入一个你要猜的数字<input type="text" id="input">
        <br>
        <input type="button" id="button" value="提交" onclick="submit()">
    </div>
    <div id="div_result">

    </div>
    <!-- <input type="button" value="点我一下" onclick="console.log('这是一个javascript')"> -->
    <script>
        function submit() {
            var masseg;
            var randonm = Math.floor(Math.random() * 10) + 1;
            var userInput = document.getElementById("input").value;
            if(userInput == randonm) {
                masseg = "<h4>恭喜你猜对了</h4>"
            }else {
                masseg = "<h4>抱歉，你猜错了,正确数字是"+randonm+"</h4>"
            }
            document.getElementById("div_result").innerHTML = masseg;

        }
        // alert('加载页面')
        // var name = prompt("你的名字是");
        // var age = prompt("你的年龄是");
        // var sex = prompt("你的性别是");
        // alert("名字->"+name+"\n"+"年龄->"+age+"\n"+"性别->"+sex);
    </script>
</body>
</html>